﻿package com.mochimedia.ui
{
	
	/**
	 * ...
	 * @author ...
	 */
	public class StringUtils {
		
		public static var monthNames:Array = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
		public static var monthShortNames:Array = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
		public static var dayNames:Array = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
			
        // 
        // 
        // PRETTYDATESTRING formats a date into display format and returns it
        public static function prettydatestring(theDate:Date):String {
            
            return dayNames[theDate.getDay()] + ", " + monthNames[theDate.getMonth()] + " " + theDate.getDate() + ", " + theDate.getFullYear();

        }
        
        
        // 
        // 
        // CGIDATESTRING formats a date into CGI encoded format and returns it
        public static function cgidatestring(theDate:Date):String {
            
            var theDay:String = "" + theDate.getDate();
            
            if (theDate.getDate() < 10) {
                theDay = "0" + theDay;
            }
            
            var theMonth:String = "" + theDate.getMonth() + 1;
   
            if ((theDate.getMonth() + 1) < 10) {
                theMonth = "0" + theMonth;
            }
            
            var theYear:String = "" + theDate.getFullYear();
            
            return theMonth + "." + theDay + "." + theYear;
            
        }
		
		//
		//
		public static function removeHTML(source:String) : String {
			
            var pattern:RegExp = /<[^>]*>/g;
            return source.replace(pattern, "");
			
        }
		
		//
		//
		public static function clean(source:String) : String {
			
			source = source.toLowerCase().split(" ").join("_");
            var pattern:RegExp = /[^a-z0-9_]/g;
            return source.replace(pattern, "");
			
        }
		
	}
	
}